home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / HD / SmartFileSystem / V1.58 / Sources / fs / blockstructure.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-11  |  5.0 KB  |  140 lines

  1. #ifndef BLOCK_STRUCTURE_H
  2. #define BLOCK_STRUCTURE_H
  3.  
  4. #include <exec/types.h>
  5.  
  6. /* a BLCK is a block number.  Blocksize in bytes = SectorSize * SectorsPerBlock.
  7.  
  8.    BLCK pointers are used throughout the filesystem.  All structures which
  9.    require to associate themselves with another structure do so using BLCK
  10.    pointers.  Byte pointers are not used. */
  11.  
  12. typedef unsigned long BLCK;
  13. typedef BLCK BLCKn;
  14.  
  15.  
  16. /* Below is the standard block header.  This header is found before EVERY
  17.    type of block used in the filesystem, except data blocks.
  18.  
  19.    The id field is used to check if the block is of the correct type when
  20.    it is being referred to using a BLCK pointer.
  21.  
  22.    The checksum field is the SUM of all LONGs in a block plus one, and then
  23.    negated.  When applying a checksum the checksum field itself should be
  24.    set to zero.  To check to see if the checksum is okay, the sum of all
  25.    longs in a block should be zero.
  26.  
  27.    The ownblock BLCK pointer points to the block itself.  This field is an
  28.    extra safety check to ensure we are using a valid block. */
  29.  
  30. struct fsBlockHeader {
  31.   ULONG id;         /* 4 character id string of this block */
  32.   ULONG checksum;   /* The checksum */
  33.   BLCK  ownblock;   /* The blocknumber of the block this block is stored at */
  34. };
  35.  
  36.  
  37.  
  38. /* Now follows the structure of the Boot block.  The Boot block is always
  39.    located at block offset 0.  It contains only a version number at the
  40.    moment to identify the block structure of the disk. */
  41.  
  42. /*
  43. struct fsBootBlock {
  44.   struct fsBlockHeader bheader;
  45.  
  46.   UWORD version;                   /* Version number of the filesystem block structure */
  47. };
  48. */
  49.  
  50. #define STRUCTURE_VERSION (3)
  51.  
  52.  
  53.  
  54. /* The fsRootInfo structure has all kinds of information about the format
  55.    of the disk. */
  56.  
  57. struct fsRootInfo {
  58.   ULONG deletedblocks;             /* Amount in blocks which deleted files consume. */
  59.   ULONG deletedfiles;              /* Number of deleted files in recycled. */
  60.   ULONG freeblocks;                /* Cached number of free blocks on disk. */
  61.  
  62.   ULONG datecreated;
  63.  
  64.   BLCK  lastallocatedblock;        /* Block which was most recently allocated */
  65.   BLCK  lastallocatedadminspace;   /* AdminSpaceContainer which most recently was used to allocate a block */
  66.   ULONG lastallocatedextentnode;   /* ExtentNode which was most recently created */
  67.   ULONG lastallocatedobjectnode;   /* ObjectNode which was most recently created */
  68.  
  69.   BLCK  rovingpointer;
  70. };
  71.  
  72.  
  73.  
  74. /* An SFS disk has two Root blocks, one located at the start of
  75.    the partition and one at the end.  On startup the fs will check
  76.    both Roots to see if it is a valid SFS disk.  If either one is
  77.    missing SFS can still continue.
  78.  
  79.    A Root block could be missing on purpose.  For example, if you
  80.    extend the partition at the end (adding a few MB's) then SFS
  81.    can detect this with the information stored in the Root block
  82.    located at the beginning (since only the end-offset has changed).
  83.    Same goes for the other way around, as long as you don't change
  84.    start and end point at the same time.
  85.  
  86.    When a Root block is missing because the partition has been
  87.    made a bit larger, then SFS will in the future be able to
  88.    'resize' itself without re-formatting the disk.
  89.  
  90.    Note: ownblock pointers won't be correct anymore when start of
  91.          partition has changed... */
  92.  
  93. struct fsRootBlock {
  94.   struct fsBlockHeader bheader;
  95.  
  96.   UWORD version;              /* Version number of the filesystem block structure */
  97.   UWORD sequencenumber;       /* The Root with the highest sequencenumber is valid */
  98.  
  99.   ULONG datecreated;          /* Creation date (when first formatted).  Cannot be changed. */
  100.   UBYTE bits;                 /* various settings, see defines below. */
  101.   UBYTE pad1;
  102.   UWORD pad2;
  103.  
  104.   ULONG reserved1[2];
  105.  
  106.   ULONG firstbyteh;           /* The first byte of our partition from the start of the */
  107.   ULONG firstbyte;            /* disk.  firstbyteh = upper 32 bits, firstbyte = lower 32 bits. */
  108.  
  109.   ULONG lastbyteh;            /* The last byte of our partition, excluding this one. */
  110.   ULONG lastbyte;
  111.  
  112.   BLCK  totalblocks;          /* size of this partition in blocks */
  113.   ULONG blocksize;            /* blocksize used */
  114.  
  115.   ULONG reserved2[2];
  116.   ULONG reserved3[8];
  117.  
  118.   BLCK  bitmapbase;           /* location of the bitmap */
  119.   BLCK  adminspacecontainer;  /* location of first adminspace container */
  120.   BLCK  rootobjectcontainer;  /* location of the root objectcontainer */
  121.   BLCK  extentbnoderoot;      /* location of the root of the extentbnode B-tree */
  122.   BLCK  objectnoderoot;       /* location of the root of the objectnode tree */
  123.  
  124.   ULONG reserved4[3];
  125. };
  126.  
  127. #define ROOTBITS_CASESENSITIVE (128)   /* When set, filesystem names are treated case
  128.                                           insensitive. */
  129. #define ROOTBITS_RECYCLED      (64)    /* When set, files being deleted will first be
  130.                                           moved to the Recycled directory. */
  131.  
  132. struct fsExtentBNode {
  133.   ULONG key;     /* data! */
  134.   ULONG next;
  135.   ULONG prev;
  136.   UWORD blocks;  /* The size in blocks of the region this Extent controls */
  137. };
  138.  
  139. #endif
  140.